#pragma once
#include <filesystem/String.hpp>
#include <game/Config.h>
#include <lib3d/node/Text.h>
#include <lib3d/node/Camera.h>
#include <lib3d/node/Root.h>

#include <Config.h>

ARELLO_GAME_NAMESPACE_DECL_START

class DebugInfoManager
{
public:
	DebugInfoManager() : fpsTime(0)
		, fpsCount(0)
		, fpsText(0)
		, camera(0)
	{}
	DebugInfoManager(const DebugInfoManager& tmp) : fpsTime(0)
		, fpsCount(0)
		, fpsText(tmp.fpsText)
		, camera(tmp.camera)
	{}
	virtual ~DebugInfoManager(){}

	void LifeCycle(time_float dt)
	{
		fpsTime += dt;
	}

	void render(liba::lib3d::hard::Hardware* hardware, lib3d::hard::RenderList* renderList)
	{
		this->fpsCount++;
		if(fabs(fpsTime - 1.0) < 0.01 || fpsTime > 1.01)
		{
			std::string text;
			converter::convert(this->fpsCount, &text);
			this->fpsTime = 0.0;
			this->fpsCount = 0;
			this->fpsText->change_text(text);

			//lib3d::hard::RenderList renderList;
			//renderList->clear_render_target = false;
			//this->camera->start_render_to_list(hardware, renderList);

			//hardware->render(renderList, hardware);
		}

		this->fpsText->GetRoot()->RenderToList(hardware, renderList);
	}

	void SetFPSNode(lib3d::node::Text* text)
	{
		fpsText = text;
	}

	void SetCamera(lib3d::node::Camera* text)
	{
		camera = text;
	}
private:
	time_float		 fpsTime;
	int              fpsCount;
	lib3d::node::Text* fpsText;
	lib3d::node::Camera* camera;

};

ARELLO_GAME_NAMESPACE_DECL_END